<?php 

include_once("./commonality.php");
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
error_reporting(E_ALL^E_NOTICE^E_WARNING);
date_default_timezone_set("PRC");
session_start();
//购物车遍历展示
$pid=$_GET['pid'];
$set="select * from product where pid={$pid}";
$res=mysql_query($set);
$product=mysql_fetch_assoc($res);
$imgg=$product['pimg'];
$pimgs=$product['pimgs'];
$rimg=explode("-", $pimgs);
$size=$product['size'];
$size1=explode("-",$size);
$color=$product['color'];
$color1=explode("-",$color);
$descp=$product['descp'];
//用户评论
$sql="select * from message where pid={$pid}";
$ers=mysql_query($sql);
while ($list=mysql_fetch_assoc($ers)) {
    	$def[]=$list;
}
$touxiang=$_SESSION['touxiang'];
$account=$_SESSION['account'];

?>

<!DOCTYPE html>
<html>
<head>
	<title></title>
</head>
<style>
	#fenlei{
			width:95%;
			height:1580px;
			/*border:1px solid blue;*/
			margin-left:35px;
	}
	.c1{
		width:10%;
		height:40px;
		/*border:1px solid red;*/
		margin-left:60px;
		font-size:18px;

	}
	.c2{
			width:30%;
			height:500px;
			/*border:2px solid #66ff33;*/
			float:left;
			margin-left:95px;
			margin-top:60px;
			}
	.c3 .big{
		width:100%;
		height:400px;
		/*border:2px solid red;*/
	}
	.c3 .small{
		width:12%;
		margin-right:10px;
		/*border:2px solid red;*/
	}
	
	.c4{
		width:41%;
		height:480px;
		/*border:1px solid red; */
		float:right;
		margin-right:100px;
		margin-top:65px;
	}
	.c5{
		width:160px;
		height:50px;
		background:#2894ff;
		display:inline-block;
		margin-top:50px;
		margin-left:50px;
		margin-right:100px;
		line-height:50px;
		text-align:center;
		color:white;
		font-size:20px;
		border-radius:4px;
	}
	.c6{
		margin-left:7px;
		margin-right:20px;
	}
	.size1{
		border:1px solid #9a9a9a;
		color:#5f5f5f;
		padding:10px;
		font-size:20px;
	}
	.size2{
		font-size:20px;
	}
	.c7{		
		margin-left:7px;
		margin-right:20px;		
	}
	.color1{
		color:#90F8FC;
		padding:10px;
		font-size:15px;
	}
	.color2{
		font-size:20px;
	}
	.color3{
		width:30px;
		height:30px;
		display:inline-block;
	}
</style>
<body>
<?php include_once("./head.php"); ?>
<span class="c1">当前所在：商城>初级课程</span><hr>
	<div id="fenlei">
		<div class="c2">
			<div class="c3">					
					<img src="./uploads/<?= $imgg ?>" class="big" id="big">
					<?php foreach ($rimg as $value) { 
					echo"<img src='./uploads/$value' class='small' onmouseover='img(this)'>";
				  }?>				
			</div>
			<script type="text/javascript">
			function img(a){
			big=document.getElementById("big");
			big.src=a.src;		 
			 }
			</script>
		</div>
		<div class="c4">
			<form action="gouwuchuli.php" method="">
			<input type="hidden" name="pid" value="<?= $product['pid'] ?>">
			<span><font size="5px"><?= $product['pname'] ?></font></span><br><br>
			<span><font size="6px">￥</b><?= $product['price'] ?></font></span><br><br>
			<hr style=" height:3px;border:none;border-top:2px dotted #1281E3;" />
			<span><font size="3px">运费：<img src="./img/8.png">编号：</b><?= $product['pnums'] ?></font></span><br>
			<hr style=" height:3px;border:none;border-top:2px dotted #1281E3;" />
			<span class="c6"><font size="5px">尺码:</font></span>
			<span class="size2">
				<?php foreach ($size1 as $value){ ?>
					<input type="radio" name="size" class="size1" value="<?= $value ?>"><?= $value ?>
				<?php } ?>
			</span>	
					<br><br>
			<span class="c7"><font size="5px">颜色:</font></span>
			<span class="color2">
				<?php foreach ($color1 as $v){ ?>
					<input type="radio" name="color" class="color1" value="<?= $v ?>">
					<div class="color3" style="background:<?= $v ?>"></div>
				<?php }?>
			</span>		
			<br><br>

			<span><b>数量：</b>
				<input type="text" name="num" value="1" size="5px">&nbsp;&nbsp;
				库存<?= $product['snums'] ?>件</span><br>
			<input type="submit" name="sub" value="加入购物车" class="c5">
		</form>
		</div>
		<div style="clear:both"></div><br>
	<span>商品描述：</span><hr>
	<span><?= $descp ?></span><hr><br>
	<span>用户评论：</span><hr>
	<?php
	if(!empty($def)){
		foreach ($def as $value){ ?>
			<span><img src="<?= $touxiang ?>" width="30px"> 
			<?= $account ?> <?= $value['mtime'] ?></span>
			<br>
			<font color="red" size="5spx">
				<?php if($value['comment']===0){ ?>
				好评
				<?php }elseif($value['comment']==1) { ?>
				中评
				<?php }elseif($value['comment']==2) { ?>
				差评
				<?php }?>
			</font>
			<span><?= $value['mcontent']?></span>
<?php } }else{echo "暂无评论"; }	?>
	</div>
</body>
</html>